package jdbc;

import demo.dao.UserMapper;

import java.sql.*;

public class kkk {
    public static void main(String[] args) {
      UserInfo userInfo=InputUtil.getInputObject(new UserInfo(),"注册功能","注册");
        try( Connection connection=DBUtil.getConnection()) {
            PreparedStatement ps = connection.prepareStatement("" +
                    "INSERT INTO userinfo(username,password,nickname,age) " +
                    "VALUES(?,?,?,?)");
            ps.setString(1,userInfo.getUsername());
            ps.setString(2,userInfo.getPassword());
            ps.setString(3,userInfo.getNickname());
            ps.setInt(4,userInfo.getAge());
            int i = ps.executeUpdate();

            if (i>0){
                System.out.println("注册成功");
            }else{
                System.out.println("注册失败");
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }


    }
}
